Page({
  data: {
    doctor: {
      id: 1,
      avatar: '',
      introduction: ''
    }
  },

  onLoad: function(options) {
    // options 包含传递过来的参数
    console.log("id: " + options.param1);

    const { init } = require('./../../wxCloudClientSDK.umd.js')
    // 指定云开发环境 ID
    wx.cloud.init({
      env: "cloud1-9gel6ndh8e555155", // 当前的云开发环境 ID
    });
    
    const client = init(wx.cloud);

    this.queryDoctor(options.param1, client);
  },

  queryDoctor(id, client) {

    client.models.swiper_info.get({
      filter: {
        where: {
         $and: [{
           _id: {
             $eq: id
           },
         },
       ],
        }
      }
    }).then(res => {
     console.log("swiper_info: " + res.data);
     
     this.parseDoctorData(res.data);
   }).catch(res => {
     console.log("swiper_info err: " + res)
   });
  },

  parseDoctorData(data) {
    const doctorInfo = {
      id: data._id,
      avatar: data.image,
      introduction: data.title,
    };

    this.setData({
      doctor: doctorInfo
    });
  }
});